//
//  StatusListViewModel.swift
//  weibo10
//
//  Created by 晁岳山 on 15/10/19.
//  Copyright © 2015年 晁岳山. All rights reserved.
//

import UIKit
/// 微博数据列表模型
class StatusListViewModel {
    lazy var statusList = [StatusViewModel]()
    func loadData(finishend: (succeed: Bool) -> () ) {
        NetworkTools.sharedTools.loadStatus { (result, error) -> () in
        
            if error != nil{
                finishend(succeed: false)
                return
            }
            //字典传模型
            guard let array = result?["statuses"] as? [[String: AnyObject]] else {
                print("返回的数据有错误")
                finishend(succeed: false)
                return
            }
            var arrayM = [StatusViewModel]();
            for dict in array {
                let dic = StatusViewModel(status: Status(dict: dict))
                arrayM.append(dic)
            }
            self.statusList = arrayM
            finishend(succeed: true)
        }

    }
}